home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / source / quickstarter / rawdofmt.asm < prev    next >
Encoding:
Assembly Source File  |  1999-12-03  |  1.4 KB  |  67 lines

  1. ;
  2. ; Simple version of the C "sprintf" function.  Assumes C-style
  3. ; stack-based function conventions.
  4. ;
  5. ;   long eyecount;
  6. ;   eyecount=2;
  7. ;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
  8. ;
  9. ; would produce "Fish have 2 eyes." in the string buffer.
  10. ;
  11.         xdef _myrawdofmt
  12.         xdef @myrawdofmt
  13.         xref _LVORawDoFmt
  14.  
  15.         SECTION myrawdofmt,CODE
  16.  
  17. _myrawdofmt:
  18.  
  19.         movem.l a2/a3/a6,-(sp)          ; save registers
  20.  
  21.         move.l  $10(sp),a3              ; get destination buffer
  22.         move.l  $14(sp),a0              ; get format string
  23.         move.l  $18(sp),a1              ; get arguments
  24.  
  25.         lea     stuffChar(pc),a2        ; get formatting routine
  26.  
  27.         move.l  4,a6
  28.         jsr     _LVORawDoFmt(a6)
  29.  
  30.         move.l  $10(sp),d0
  31.  
  32.         movem.l (sp)+,a2/a3/a6          ; restore registers
  33.  
  34.         rts
  35.  
  36. @myrawdofmt:
  37.  
  38. ; myrawdofmt(buffer, template, args)
  39. ;             a0       a1      a2
  40.  
  41.         movem.l a2/a3/a6,-(sp)
  42.  
  43. ; NextData = RawDoFmt(FormatString, DataStream, PutChProc, PutChData);
  44. ;   d0                   a0             a1         a2         a3
  45.  
  46.         movea.l a0,a3
  47.         movea.l a1,a0
  48.         movea.l a2,a1
  49.         lea.l   stuffChar(pc),a2
  50.  
  51.         move.l  4,a6
  52.         jsr     _LVORawDoFmt(a6)
  53.  
  54.         movem.l (sp)+,a2/a3/a6
  55.         move.l  4(sp),d0
  56.  
  57.         rts
  58.  
  59. ;------ PutChProc function used by RawDoFmt -----------
  60.  
  61. stuffChar:
  62.  
  63.         move.b  d0,(a3)+
  64.         rts
  65.  
  66.         END
  67.